﻿using System;
using System.Collections.Generic;
using System.ServiceModel;
using StockholmsStad.Business;
using StockholmsStad.Runtime.Serialization.DataContract.Enums;
using StockholmsStad.Utilities.Exceptions;
using StockholmsStad.Runtime.Serialization.DataContract;
using StockholmsStad.ServiceModel.Interfaces;

namespace StockholmsStad.ServiceModel.Services
{
    /// <summary>
    /// Detta är serviceimplementationsklassen för servicen IUserService.
    /// </summary>
    public class UserService : IUserService
    {
        #region IUserService Members


        /// <summary>
        /// 
        /// </summary>
        /// <param name="user"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public void RemoveParvisUser(User user, int userId)
        {
            try
            {
                var userBusiness = new UserBusiness(user);
                userBusiness.RemoveParvisUser(userId);
            }
            catch (StockholmStadSystemException e)
            {
                throw new FaultException<StockholmStadSystemErrorFault>(new StockholmStadSystemErrorFault(e.ErrorCode, e.Message));
            }
            catch (StockholmStadApplicationException e)
            {
                throw new FaultException<StockholmStadApplicationErrorFault>(new StockholmStadApplicationErrorFault(e.ErrorCode, e.Message));
            }
        }

        #endregion
    }
}
